class Solution:
    def countSubstr(self , s , t ):
        # write code here
        sstr = self.substr(s)
        tstr = self.substr(t)
        res = 0
        for s in sstr:
            for t in tstr:
                if self.isvalid(s, t):
                    res += 1
        return res 
    def substr(self,s):
        substr = []
        n = len(s)
        for i in range(1,n+1):
            for j in range(n-i+1):
                substr.append(s[j:j+i])
        return substr
    def isvalid(self,s,t):
        n1 = len(s)
        n2 = len(t)
        if n1 != n2:
            return False
        c = 0
        for i in range(n1):
            if s[i] != t[i]:
                c += 1
        return c==1